GoXam for WPF v3
Read<T>(XName,XElement,T,Func<String,T>) Method
Northwoods.GoXam.Model Namespace > XHelper Class > Read Method : Read<T>(XName,XElement,T,Func<String,T>) Method
the value type
the name of the attribute
the XElement that may have an XAttribute with the name n
the default value to return if there's no attribute named n or if the attribute value string cannot be converted to the value type
a function from String to T
This generic method produces a property value from an XElement's attribute value, using a conversion function to convert the string to the expected type, and returning a default value if the conversion fails.
Syntax
public static T Read<T>( 
   XName n,
   XElement e,
   T defval,
   Func<string,T> conv
)

Parameters

n
the name of the attribute
e
the XElement that may have an XAttribute with the name n
defval
the default value to return if there's no attribute named n or if the attribute value string cannot be converted to the value type
conv
a function from String to T

Type Parameters

T
the value type

Return Value

either the attribute value string converted to T, or else the defval
See Also

Reference

XHelper Class
XHelper Members
Overload List